<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set value="${pageContext.request.contextPath}" var="ctx" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv=Content-Type content=text/html;charset=gb2312>
<link href="${ctx }/css/skin.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript">
	var oldtitle = top.document.title;
	var timerID = null;
	$(document).ready(
			function() {
				var days = [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" ];
				$("#spanWel").text(
						"您好，今天是" + new Date().toLocaleDateString() + "，"+ days[new Date().getDay()]);
				var interval;
				function run() {
					interval = setInterval(getMsg, "300000");
				}
				function getMsg() {
					var obj = {};
					obj.type = 'getnew';
					$.ajax({
						url : '${ctx}/msg/post',
						type : 'post',
						data : obj,
						dataType : 'json',
						success : function(data) {
							if (data.code == 200) {
								var rows = data.data;
								$("#spanNewMsg").text(
										"您有" + rows.length + "条新消息");
								startRoll();
								$("#spanNewMsg").show();
								$("#spanNewMsg").click(function(){
									$("#spanNewMsg").hide();
									$("#spanNewMsg").text("");
									window.parent.frames["main"].location.href="${ctx}/jsp/dataMgt/message-list.jsp";
								});
							} else {
								$("#spanNewMsg").hide();
								$("#spanNewMsg").text("");
							}
						}
					});
				}
				//if(${user.userId}==${zlid}){
					getMsg();
					run();
				//}
			});
	/**
	 * 开始滚动字幕
	 */
	var stepCount = 0;
	var step = 0;
	function startRoll() {
		stepCount++;
	    step++;
	    if(step==3){step=1;}
	    if(stepCount == 6){stopRoll();return;}
	    if(step==1){top.document.title='【　　　】'+oldtitle;}
	    if(step==2){top.document.title='【新消息】'+oldtitle;}
	    timerID = setTimeout("startRoll()", 1000);
	}

	/**
	 * 停止滚动字幕
	 */
	function stopRoll(){
		clearTimeout(timerID);
		timerID = null;
		stepCount = 0;
		top.document.title = oldtitle;
	}
</script>
</head>
<body leftmargin="0" topmargin="0">
	<table width="100%" height="64" border="0" cellpadding="0"
		cellspacing="0" class="admin_topbg">
		<tr>
			<td width="61%" height="64"></td>
			<td width="39%" valign="top"><table width="100%" border="0"
					cellspacing="0" cellpadding="0">
					<tr>
						<td width="74%" height="38" class="admin_txt"><b>${user.username }</b>
							<span id="spanWel"></span></td>
						<td width="22%"><a href="${ctx}/login/delete"
							target="_parent"><img src="${ctx }/images/out.gif" alt="安全退出"
								width="46" height="20" border="0"></a></td>
						<td width="4%">&nbsp;</td>
					</tr>
					<tr>
						<td height="19" colspan="3">&nbsp;</td>
					</tr>
				</table></td>
		</tr>
	</table>
	<span id="spanNewMsg"></span>
</body>
</html>
